import {createRouter, createWebHashHistory,createWebHistory} from 'vue-router'
import HomeView from "@/views/HomeView.vue";
import SearchView from "@/views/SearchView.vue";
import NotFind from "@/views/NotFind.vue"
const router = createRouter({
  history: createWebHashHistory(),
  // 配置路由模式: 默认是hash模式, 还有history模式
  // createWebHashHistory() -> hash模式 -> 路径中带#
  // createWebHistory() -> history模式 -> 路径中不带#
  // history: createWebHistory(),
  routes: [
    // 路由重定向
    {path:'/',redirect:'/home'},
    {name:'home' , path: '/home', component: HomeView },
    // 动态路由传参----/: ----?可选
    {name:'search' ,path:'/search/:words?',component:SearchView},
    // 404页面放在路由规则数组的最后面
    {path:'/:catchAll(.*)',component:NotFind}
  ]
})

export default router